#ifndef INC_SPINLOCK_H
#define INC_SPINLOCK_H

struct spinlock {
    volatile int locked;

    /* For debugging: */
    char        *name;      /* Name of lock. */
    struct cpu  *cpu;       /* The cpu holding the lock. */
};

int holding(struct spinlock *lk);
void acquire(struct spinlock *lk);
void release(struct spinlock *lk);
void initlock(struct spinlock *lk, char *name);
int try_acquire(struct spinlock *lk);
void waitlock(struct spinlock *lk);

#endif
